<template>
  <div class="home">
    <!-- 顶部栏 -->
    <header class="header">
      <img class="logo" src="@/assets/logo.png" alt="Logo" />
      <div class="search-box">
        <input type="text" placeholder="搜索" />
      </div>
      <div class="notification">
        <img src="@/assets/icons/notification.png" alt="通知" />
      </div>
    </header>

    <!-- 功能区 -->
    <div class="function-area">
      <div v-for="item in functions" :key="item.id" class="function-item">
        <img :src="item.icon" :alt="item.name" />
        <span>{{ item.name }}</span>
      </div>
    </div>

    <!-- 推荐文章区域 -->
    <div class="article-section">
      <div class="article-grid">
        <div v-for="article in articles" 
             :key="article.id" 
             class="article-card">
          <div class="article-image">
            <img :src="article.image" :alt="article.title" />
          </div>
          <div class="article-info">
            <h3>{{ article.title }}</h3>
            <p>{{ article.description }}</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const functions = ref([
  { id: 1, name: '宠物护理', icon: '/icons/care.png' },
  { id: 2, name: '诊疗', icon: '/icons/medical.png' },
  { id: 3, name: '宠物用品', icon: '/icons/supplies.png' },
  { id: 4, name: '训练', icon: '/icons/training.png' }
])

const articles = ref([
  {
    id: 1,
    title: '如何照顾幼犬',
    description: '新手养狗必看指南',
    image: '/articles/puppy.jpg'
  }
  // ... 更多文章数据
])
</script>

<style scoped>
.home {
  min-height: 100vh;
  background: var(--color-white);
}

.header {
  position: fixed;
  top: 0;
  width: 100%;
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: var(--color-primary);
  z-index: 100;
}

.logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.search-box {
  flex: 1;
  margin: 0 16px;
  background: var(--color-white);
  border-radius: 20px;
  padding: 8px 16px;
}

.search-box input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
}

.function-area {
  margin-top: 60px;
  display: flex;
  justify-content: space-around;
  padding: 20px 0;
  background: var(--color-secondary);
}

.function-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.function-item img {
  width: 50px;
  height: 50px;
}

.article-section {
  padding: 16px;
}

.article-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.article-card {
  background: var(--color-white);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.article-image {
  position: relative;
  padding-top: 133.33%; /* 3:4 比例 */
}

.article-image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.article-info {
  padding: 12px;
}

.article-info h3 {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 4px;
}

.article-info p {
  font-size: 14px;
  color: var(--color-gray);
}
</style> 